package de.szut.tiktaktoe.gui;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;


@SuppressWarnings("serial")
public class GameField extends JPanel implements InterfaceField{

	private JPanel contentPane;
	private JLabel fieldLbl;
	private int spacex;
	private int spacey;
	private int x;
	private int y;
	private JLabel[][] fieldList = new JLabel[3][3];
	private Listener listen = new Listener();
	@SuppressWarnings("unused")
	private MainFrame mframe;
	
	public GameField() {
		mframe = new MainFrame();
		setSize(200, 200);
		contentPane = new JPanel();
		contentPane.setLayout(null);		
		
		spacey = 0;
		for (x = 0; x < 3; x++){
			spacex = 0;
			if (x % 3 == 0 && x != 0){
				spacey = spacey + 10;
			}
			for (y = 0; y < 3; y++){
				fieldLbl= new JLabel();
				if (y % 3 == 0 && y != 0){
					spacex = spacex + 10;
				}
				
				fieldLbl.setLocation(25 + (x* 50) + spacey, 15 + (y *50) + spacex);
				fieldLbl.setSize(45, 45);
				fieldLbl.setOpaque(true);
				fieldLbl.setBackground(Color.RED);
				fieldLbl.setHorizontalAlignment(SwingConstants.CENTER);
				fieldLbl.setFont(new Font("Tahoma", Font.PLAIN, 19));
				fieldLbl.setForeground(Color.GREEN);
				add(fieldLbl);
				fieldLbl.addMouseListener(listen);
				fieldList[x][y] = fieldLbl;
			}
		}
	}
	public JPanel getField(){
		return this;
	}
	public JLabel[][] getArray(){
		return fieldList;
	}
	@Override
	public void refreshPlayingField(char[][] fieldList) {
	}
	@Override
	public int endGame(int player) {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void startRound() {
		// TODO Auto-generated method stub
		
	}

}
